class_name BallStateShoot
extends BallState

const SHOT_HEIGHT := 5
const SHOT_SPRITE_SCALE := 0.8
const DURACTION_SHOT := 1000.0

var time_since_shot :float = Time.get_ticks_msec()

func _enter_tree() -> void:
	set_ball_animation_from_velocity()
	ball.height = SHOT_HEIGHT
	ball_sprite.scale.y = SHOT_SPRITE_SCALE
	time_since_shot = Time.get_ticks_msec()
	shot_particles.emitting =  true
	GameEvents.impact_received.emit(ball.position, true)
		
func _process(delta: float) -> void:
	if Time.get_ticks_msec() - time_since_shot > DURACTION_SHOT:
		transaction_state(Ball.State.FREEDOM)
	move_and_bounce(delta)

func _exit_tree() -> void:
	ball_sprite.scale.y = 1
	shot_particles.emitting = false
